﻿using System;
using System.Collections.Generic;
using System.Web;
using PayRoller.Code;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using HySoft.Cash.Business;
using HySoft.Cash.Structure;
using System.Configuration;
using System.Web.Profile;
using Huayou.UI.WebControls;
using System.Data;
using Huayou.Common;
using System.Data.SqlClient;
using HySoft.Cash.BaseClass;

namespace PayRoller.Manage.OrgInfo
{
    public class EmpUptHistory : ParentPage, IRequiresSessionState
    {
        // Fields
        protected Huayou.UI.WebControls.DataGridTable dgdList;
        protected DropDownList DropDownList1;
        public string EmpSid = "";
        protected HtmlForm form1;
        protected Label lblTip;
        public string OrgSid = "";
        protected TextBox txtParamstr;

        // Methods
        protected void dgdList_DataBinding(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@OrgSid", this.OrgSid), new SqlParameter("@EmpSid", this.EmpSid) };
            dt = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["SQLConnString"], CommandType.StoredProcedure, "GetUptReport", commandParameters).Tables[0];
            CommonBasePage.SetPage(this.dgdList, dt);
            base.AddValue("pageno", Convert.ToString((int)(this.dgdList.CurrentPageIndex + 1)));
            this.txtParamstr.Text = base.PackPart(base.ParamValue);
        }

        protected void dgdList_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
        {
            this.dgdList.CurrentPageIndex = e.NewPageIndex;
            this.dgdList.DataBind();
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.dgdList.DataBind();
        }

        public void GetEmpInfo(int OrgSid)
        {
            ListItem item = new ListItem("--Please Select--", "-1");
            TempinfoBN obn = new TempinfoBN(this.Page);
            obn.QueryOrgSid(OrgSid);
            DataTable list = obn.GetList();
            for (int i = 0; i < list.Rows.Count; i++)
            {
                item = new ListItem(list.Rows[i]["Sid"].ToString() + "-" + list.Rows[i]["EmpName"].ToString(), list.Rows[i]["Sid"].ToString());
                this.DropDownList1.Items.Add(item);
            }
            obn.Dispose();
            obn = null;
        }

        protected override void OnInit(EventArgs e)
        {
            base.m_ModuleCode = "";
            base.CheckLogin(true);
            base.CheckPerm();
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.Request["OrgSid"] != null)
            {
                this.OrgSid = base.Request["OrgSid"].ToString();
            }
            if (base.Request["Sid"] != null)
            {
                this.EmpSid = base.Request["Sid"].ToString();
            }
            if (!this.Page.IsPostBack)
            {
                base.ParamValue = base.UnPack();
                this.txtParamstr.Text = base.PackPart(base.ParamValue);
                string str = base.GetValue("pageno");
                if (str != null)
                {
                    this.dgdList.CurrentPageIndex = Convert.ToInt32(str) - 1;
                }
                this.dgdList.DataBind();
            }
            else
            {
                base.ParamValue = base.UnPackPart(this.txtParamstr.Text);
            }
        }

        // Properties
        protected HttpApplication ApplicationInstance
        {
            get
            {
                return this.Context.ApplicationInstance;
            }
        }

        protected DefaultProfile Profile
        {
            get
            {
                return (DefaultProfile)this.Context.Profile;
            }
        }
    }

}
